file(GLOB protobuf_files *.proto)
find_package(Protobuf REQUIRED)
SET(PROTO_META_BASE_DIR ${CMAKE_CURRENT_BINARY_DIR})
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory "${PROTO_META_BASE_DIR}" RESULT_VARIABLE result)

FOREACH(FIL ${protobuf_files})
    message("gen pb file")
    GET_FILENAME_COMPONENT(FILE_NAME ${FIL} NAME)
    GET_FILENAME_COMPONENT(FILE_PATH ${FIL} DIRECTORY)
    EXECUTE_PROCESS(
            COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${FIL} -I${FILE_PATH} --cpp_out=${PROTO_META_BASE_DIR}
    )
ENDFOREACH()


execute_process(COMMAND date "+%Y/%m/%d %H:%M:%S" OUTPUT_VARIABLE DATETIME)
#string(REGEX REPLACE "\n" "" DATETIME ${DATETIME})
set(GIT_DATE_TIME "${DATETIME}")
set(GIT_SHA 0)
set(BUILD_VERSION_CC ${CMAKE_CURRENT_BINARY_DIR}/build_version.cc)
configure_file(build_version.cc.in  ${BUILD_VERSION_CC} @ONLY)

aux_source_directory(. ROOT_DIR)
aux_source_directory(threads PIKA_THREADS)
aux_source_directory(presentation PRESENTATION)  # 表示层
aux_source_directory(cmd CMD)  # redis cmd处理

add_definitions(-W -Wextra -Wall -Wsign-compare -Wno-unused-parameter -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers)
add_definitions(-fno-builtin-memcmp -msse -msse4.2 -fno-omit-frame-pointer -DNDEBUG -momit-leaf-frame-pointer)

include_directories(
        ${PROJECT_BINARY_DIR}
        ${PROJECT_SOURCE_DIR}/third/slash
        ${PROJECT_SOURCE_DIR}/third/pink
        ${PROJECT_SOURCE_DIR}/third/nemo-rocksdb
        ${PROJECT_SOURCE_DIR}/third/nemo-rocksdb/include
        ${PROJECT_SOURCE_DIR}/third/nemo
        ${PROJECT_SOURCE_DIR}/third/nemo/include
        ${PROJECT_SOURCE_DIR}/third/rocksdb
        ${PROJECT_SOURCE_DIR}/third/rocksdb/include
)

link_directories(
        ${PROJECT_SOURCE_DIR}/lib
        ${PROJECT_BINARY_DIR}/third/rocksdb
)

set(SRCS ${BUILD_VERSION_CC} ${ROOT_DIR} ${PIKA_THREADS} ${PRESENTATION} ${CMD})
set(ROCKS_LIB pthread lz4 z  snappy)
set(LIBS gflags glog protobuf nemo nemodb rocksdb pink slash)
add_executable(pika ${SRCS})
target_link_libraries(pika ${LIBS} ${ROCKS_LIB})

